import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class Mountain extends MoveBckGr
{
    private Actor m;
    private int level;
    private World world;
    private int distance;
    private Message message;

    /**
     * Mountain Constructor. It receives the level.
     */
    public Mountain(int l)
    {
        level = l;
    }

    /**
     * Method act.
     */
    public void act() 
    {
        distance = shift( super.getX(), super.getY(), 3, 1, level);
        m = getOneIntersectingObject( Man.class);
        if ( m != null)
            if( ( ( Man)m).getY() <= ( super.getY() - 175))
            {
                message = new Message("YOU WIN");
                world = getWorld();
                world.addObject (message, 250, 150);
                Greenfoot.delay(10);
                if ( level == 1)                                //Scenario 1 to Scenario 2
                    Greenfoot.setWorld(new Sun( distance) );
                else
                if( level == 2)                                 //Scenario 2 to Menu.
                    Greenfoot.setWorld(new Menu( distance) );
                else
                    Greenfoot.stop( );
        }
    }    

    /**
     * Method top. It returns the y position of the top.
     */
    public int top()
    {
        return( super.getY()-175);
    }
}